const mongoose = require('mongoose');

const systemSettingSchema = mongoose.Schema(
  {
    systemName: {
      type: String,
      required: true,
      trim: true,
    },
    systemVersion: {
      type: String,
      required: true,
      trim: true,
    },
    adminEmail: {
      type: String,
      required: true,
      trim: true,
    },
    contactPhone: {
      type: String,
      required: true,
      trim: true,
    },
    cacheTime: {
      type: Number,
      default: 30, // 默认缓存30分钟
    },
    pageSize: {
      type: Number,
      default: 10, // 默认每页10条
    },
    defaultLanguage: {
      type: String,
      default: 'zh-CN',
      trim: true,
    },
    timezone: {
      type: String,
      default: 'Asia/Shanghai',
      trim: true,
    },
    features: {
      userRegistration: {
        type: Boolean,
        default: true,
      },
      userRecipeCreation: {
        type: Boolean,
        default: true,
      },
      autoNutritionAnalysis: {
        type: Boolean,
        default: true,
      },
      userFoodContribution: {
        type: Boolean,
        default: true,
      },
      maintenanceMode: {
        type: Boolean,
        default: false,
      },
    },
    isDeleted: {
      type: Boolean,
      default: false,
    },
  },
  {
    timestamps: true,
  }
);

/**
 * @typedef SystemSetting
 */
const SystemSetting = mongoose.model('SystemSetting', systemSettingSchema, 'system_settings');

module.exports = SystemSetting; 